<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sets the RNG seed</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.gmp-random-seed" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gmp_random_seed</h1>
  <p class="verinfo">(PHP 7)</p><p class="refpurpose"><span class="refname">gmp_random_seed</span> &mdash; <span class="dc-title">Sets the RNG seed</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.gmp-random-seed-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>gmp_random_seed</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$seed</code></span>
   ) : <span class="type"><span class="type void">void</span></span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.gmp-random-seed-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">seed</code></dt>

     <dd>

      <p class="para">
       The seed to be set for the <span class="function"><a href="gmp_random.html" class="function">gmp_random()</a></span>,
       <span class="function"><a href="gmp_random_bits.html" class="function">gmp_random_bits()</a></span>, and
       <span class="function"><a href="gmp_random_range.html" class="function">gmp_random_range()</a></span> functions.
      </p>

      <p class="para">可以是一个 GMP
数据 <span class="type"><span class="type resouce">resouce</span></span>，或一个可以转换为数值的字符串。</p> 
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.gmp-random-seed-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>NULL</code></strong> on success 或者在失败时返回 <strong><code>FALSE</code></strong>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.gmp-random-seed-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Issues an <strong><code>E_WARNING</code></strong> and returns <strong><code>FALSE</code></strong> if
   <code class="parameter">seed</code> is not valid.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.gmp-random-seed-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4095">
    <p><strong>Example #1 <span class="function"><strong>gmp_random_seed()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;set&nbsp;the&nbsp;seed<br /></span><span style="color: #0000BB">gmp_random_seed</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">gmp_random</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">)));<br /><br /></span><span style="color: #FF8000">//&nbsp;set&nbsp;the&nbsp;seed&nbsp;to&nbsp;something&nbsp;else<br /></span><span style="color: #0000BB">gmp_random_seed</span><span style="color: #007700">(</span><span style="color: #0000BB">gmp_init</span><span style="color: #007700">(-</span><span style="color: #0000BB">100</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">gmp_strval</span><span style="color: #007700">(</span><span style="color: #0000BB">gmp_random_bits</span><span style="color: #007700">(</span><span style="color: #0000BB">10</span><span style="color: #007700">)));<br /><br /></span><span style="color: #FF8000">//&nbsp;set&nbsp;the&nbsp;seed&nbsp;to&nbsp;something&nbsp;invalid<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">gmp_random_seed</span><span style="color: #007700">(</span><span style="color: #DD0000">'not&nbsp;a&nbsp;number'</span><span style="color: #007700">));</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(20) &quot;15370156633245019617&quot;
string(3) &quot;683&quot;

Warning: gmp_random_seed(): Unable to convert variable to GMP - string is not an integer in %s on line %d
bool(false)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.gmp-random-seed-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="gmp_init.html" class="function" rel="rdfs-seeAlso">gmp_init()</a> - Create GMP number</span></li>
   <li class="member"><span class="function"><a href="gmp_random.html" class="function" rel="rdfs-seeAlso">gmp_random()</a> - Random number</span></li>
   <li class="member"><span class="function"><a href="gmp_random_bits.html" class="function" rel="rdfs-seeAlso">gmp_random_bits()</a> - Random number</span></li>
   <li class="member"><span class="function"><a href="gmp_random_range.html" class="function" rel="rdfs-seeAlso">gmp_random_range()</a> - Random number</span></li>
  </ul>
 </div>


</div></div></div></body></html>